<!--
  Copyright JS Foundation and other contributors, http://js.foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<script type="text/html" data-help-name="template">
    <p>Sets a property based on the provided template.</p>
    <h3>Inputs</h3>
    <dl class="message-properties">
        <dt>msg <span class="property-type">object</span></dt>
        <dd>A msg object containing information to populate the template.</dd>
        <dt class="optional">template <span class="property-type">string</span></dt>
        <dd>A template to be populated from <code>msg.payload</code>. If not configured in the edit panel,
         this can be set as a property of msg.</dd>
    </dl>
    <h3>Outputs</h3>
    <dl class="message-properties">
        <dt>msg <span class="property-type">object</span></dt>
        <dd>a msg with a property set by populating the configured template with properties from the incoming msg.</dd>
    </dl>
    <h3>Details</h3>
    <p>By default this uses the <i><a href="http://mustache.github.io/mustache.5.html" target="_blank">mustache</a></i>
    format, but this can be switched off if required.</p>
    <p>For example, when a template of:
    <pre>Hello {{payload.name}}. Today is {{date}}</pre>
    <p>receives a message containing:
    <pre>{
  date: "Monday",
  payload: {
    name: "Fred"
  }
}</pre>
    <p>The resulting property will be:
    <pre>Hello Fred. Today is Monday</pre>
    <p>It is possible to use a property from the flow context or global context. Just use <code>{{flow.name}}</code> or
    <code>{{global.name}}</code>, or for persistable store <code>store</code> use <code>{{flow[store].name}}</code> or
    <code>{{global[store].name}}</code>.
    <p><b>Note: </b>By default, <i>mustache</i> will escape any non-alphanumeric or HTML entities in the values it substitutes.
       To prevent this, use <code>{{{triple}}}</code> braces.</p>
    <p>If you need to use <code>{{ }}</code> within your content, you can change the characters
       used to mark the templated sections. For example, to use <code>[[ ]]</code>
       instead, add the following line to the top of the template:</p>
    <pre>{{=[[ ]]=}}</pre>
    <h4>Using environment variables</h4>
    <p>The template node can access environment variables using the syntax:</p>
    <pre>My favourite colour is {{env.COLOUR}}.</pre>
</script>
